import request from '@/utils/request'

// 查询退款申请列表
export function listRefundApply(query) {
  return request({
    url: '/order/refundApply/list',
    method: 'get',
    params: query
  })
}

// 查询退款申请详细
export function getRefundApply(id) {
  return request({
    url: '/order/refundApply/' + id,
    method: 'get'
  })
}

// 新增退款申请
export function addRefundApply(data) {
  return request({
    url: '/order/refundApply',
    method: 'post',
    data: data
  })
}

// 修改退款申请
export function updateRefundApply(data) {
  return request({
    url: '/order/refundApply',
    method: 'put',
    data: data
  })
}

// 删除退款申请
export function delRefundApply(id) {
  return request({
    url: '/order/refundApply/' + id,
    method: 'delete'
  })
}

export function updateRefundApplyStatus(refundId, newStatus) {
  // 构建请求体，包含退款申请的 ID 和新状态码
  const data = {
    id: refundId,
    status: newStatus
  };

  // 返回请求结果
  return request({
    url: '/order/refundApply', // 后端接口的 URL
    method: 'put', // 请求方法
    data: data // 发送到后端的数据
  })
}